<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增【客户信息】')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-client-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">客户名称：</label>
                <div class="col-sm-8">
                    <input name="nameClient" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group container">
                <label class="col-sm-3 control-label is-required">所在城市:</label>
                <select id="shi"  class="btn btn-default dropdown-toggle" style="margin-left:12px " onblur="zhenUpdate()">
                    <option value="" >所有</option>
                </select>
                <select id="zhen" class="btn btn-default dropdown-toggle" style="margin-left:12px "  name="regionClient">
                    <option value="">所有</option>
                </select>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">详细地址：</label>
                <div class="col-sm-8">
                    <textarea name="addressStreetClient" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">手机：</label>
                <div class="col-sm-8">
                    <input name="phoneNum1Client" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">紧急联系人：</label>
                <div class="col-sm-8">
                    <input name="phoneNum2Client" class="form-control" type="text">
                </div>
            </div>
            <!--<div class="form-group">
                <label class="col-sm-3 control-label">交易次数：</label>
                <div class="col-sm-8">
                    <input name="transTimeClient" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">信用度：</label>
                <div class="col-sm-8">
                    <input name="creditClient" class="form-control" type="text" required>
                </div>
            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        $(function(){
            $("#shi").html("");
            let url = "/system/region/listById";
            let param = {"parentId":27425};
            $.getJSON(url,param,function(json){
                let rows = json.rows;
                $(rows).each(function(i,item){
                    let html = '';
                    html += '<option value='+item.idRegion+'>'+item.nameRegion+'</option>';
                    $("#shi").append(html);
                })
            })
        })
        var prefix = ctx + "system/client"
        $("#form-client-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-client-add').serialize());
            }
        }

        function zhenUpdate(){
            $("#zhen").html("");
            let url = "/system/region/listById";
            let parentId = $("#shi").val();
            let param = {"parentId":parentId};
            $.getJSON(url,param,function(json){
                let rows = json.rows;
                console.log(rows);
                $(rows).each(function(i,item){
                    let html = '';
                    html += '<option value='+item.idRegion+'>'+item.nameRegion+'</option>';
                    $("#zhen").append(html);
                })
            })
        }
        /*function cunUpdate(){
            $("#cun").html("");
            let url = "/system/region/listById";
            let parentId = $("#zhen").val();
            let param = {"parentId":parentId};
            $.getJSON(url,param,function(json){
                let rows = json.rows;
                $(rows).each(function(i,item){
                    let html = '';
                    html += '<option value='+item.idRegion+'>'+item.nameRegion+'</option>';
                    $("#cun").append(html);
                })
            })
        }*/

    </script>
</body>
</html>